/* GLVertexArrayTexture.h
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <GL/gl.h>
#include <graphics/GLVertexArray.h>
#include <graphics/GLVertexData.h>

#ifndef GLVERTEXARRAYTEXTURE_H_
#define GLVERTEXARRAYTEXTURE_H_

template <typename Tdata, typename Ttex>
class GLVertexArrayTexture : public GLVertexArray<Tdata>
{
private:
	GLVertexData<Ttex>* arrayTexture;

public:
	GLVertexArrayTexture(GLVertexData<Tdata>* data, GLVertexData<Ttex>* texture)
		: GLVertexArray<Tdata>(data), arrayTexture(texture) {};
	~GLVertexArrayTexture() {};

	void setupPointers()
	{
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glVertexPointer(GLVertexArray<Tdata>::arrayData->getComponentCount(), GL_FLOAT, 0,
				GLVertexArray<Tdata>::arrayData->getAddress());
		glTexCoordPointer(arrayTexture->getComponentCount(), GL_FLOAT, 0,
			arrayTexture->getAddress());
	}

	void cleanupPointers()
	{
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
	}
};

#endif /* GLVERTEXARRAYTEXTURE_H_ */
